package info.techgeek.labs.java5Features.generics.method;

import java.util.ArrayList;
import java.util.Collection;

public class MethodTest {

	public static void main(String[] args) {

		// Test 1 Works Fine
		// ArrayList<Integer> lst1 = new ArrayList<Integer>();
		// lst1.add(1);
		// lst1.add(2);
		// lst1.add(3);
		//
		// ArrayList<Integer> lst2 = new ArrayList<Integer>();
		// filter(lst1, lst2);
		// System.out.println(lst2.size());

		// Test 2 Works Fine
		ArrayList<Integer> lst3 = new ArrayList<Integer>();
		ArrayList lst = new ArrayList();
		lst.add("hello");
		filter(lst, lst3);
		System.out.println(lst3.size());
		System.out.println(lst3.get(0));

		for (Integer val : lst3) {
			System.out.println(val);
		}
	}

	public static <T> void filter(Collection<T> in, Collection<T> out) {
		boolean flag = true;
		for (T obj : in) {
			if (flag) {
				out.add(obj);
			}
			flag = !flag;
		}
	}
}
